package com.googlecode.cswish.util.crosssite;

import java.util.Map;

import com.googlecode.cswish.struts.spring.CrossSiteCache;
import com.googlecode.cswish.struts.spring.Executor;
import com.googlecode.cswish.util.WebsiteUtil;

public class CrossSiteCacheMap<V> extends CrossSiteHashMap<String, V> implements CrossSiteCache<V> {

	private static final long serialVersionUID = 2867832211148840173L;
	
	public CrossSiteCacheMap(Map<String, V> initValues) {
		super(initValues);
	}
	
	public CrossSiteCacheMap(Map<String, V> initValue, Executor<Map<String, V>, Object> factory) {
		super(initValue, factory);
	}
	
	@Override
	public V get(Object key) {
    	V value = super.get(key);
    	return value;
    }
    	
	@Override
    public void removeAll(String key) {
		for (String website : WebsiteUtil.getWebsites()) {
			String newKey = WebsiteUtil.getKey(website, key);
			super.remove(newKey);
		}
	}
}